package com.algorithms;

import com.algorithms.heap.Heap;
import com.algorithms.utils.AlgorithmException;
import com.algorithms.utils.Utils;

public class test_heap extends Thread {
	public void run(){
		// add some samples to heap
		Heap<Integer> heap = new Heap<Integer>(100);
		int[] ranNums = Utils.genRandomInts(20, 1000);
		for (int i = 0; i < ranNums.length; i++){
			try{
				heap.insert(ranNums[i], ranNums[i]);
			}catch(AlgorithmException alEx){
				System.err.println(alEx.getMessage());
			}
		}
		heap.printHeap();
		
		// try to delete some elements
		try{
			heap.delete();
			heap.delete();
			heap.delete();
			heap.delete();
			heap.delete();
			heap.delete();
			
		}catch(AlgorithmException alEx){
			System.err.println(alEx.getMessage());
		}
		
		heap.printHeap();
	}
	
	public static void main(String args[]){
		new test_heap().start();
	}
}
